<?php
// function.cdn.php
/**
* Smarty cdn插件，根据文件修改时间设置版本号
* @author Robot
* @date 2013-12-18
* 
<html>
	<head>
	<%cdn type="css" href="css/touch/all.css"%>
	<%cdn type="javascript" href="js/touch/base.js"%>
	</head>

</html>

*/
function smarty_function_cdn($params, &$smarty)
{
	$file = BASE_DIR.'webroot/static/'.$params['href'];
	$t = file_exists($file) ? filemtime(BASE_DIR.'webroot/static/'.$params['href']) : '00000000';

	switch($params['type'])
	{
		case "css":
			$html = '<link rel="stylesheet" href="'.STATIC_URL.$params['href'].'?'.substr($t,-8, 8).'" />';
			break;
		case "javascript":
			$html = '<script type="text/javascript" src="'.STATIC_URL.$params['href'].'?'.substr($t,-8, 8).'"></script>';
			break;
		default:
			$html = "";
	}

	return $html;
}

?>